package com.project.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("session")
public class SessionController {
    @RequestMapping("getSession")
    public String getSession(HttpServletRequest request){
        //如果服务器端有客户端对应的session对象则直接取出
        //否则创建新的session对象
        HttpSession session = request.getSession();
        String str = session.getId();
        return "sessionId:"+str;
    }
}
